;d3d9.h, d3d9types.h, d3d9caps.h
;Copyright (C) Microsoft Corporation.  All Rights Reserved.
;File:   d3d9.h
;Content:    Direct3D include file

DIRECT3D_VERSION = $900
;D3D_DEBUG_INFO
;D3D_SDK_VERSION = (32 or $80000000)
;D3D9b_SDK_VERSION (31 or $80000000)
D3D_SDK_VERSION = 32
D3D9b_SDK_VERSION = 31
D3D_OK = S_OK

;IID_IDirect3D9 GUID $81bdcbca,$64d4,$426d,<$ae,$8d,$ad,1,$47,$f4,$27,$5c>
;IID_IDirect3DDevice9 GUID $d0223b96,$bf7a,$43fd,<$92,$bd,$a4,$3b,$d,$82,$b9,$eb>
;IID_IDirect3DResource9 GUID $5eec05d,$8f7d,$4362,<$b9,$99,$d1,$ba,$f3,$57,$c7,$4>
;IID_IDirect3DBaseTexture9 GUID $580ca87e,$1d3c,$4d54,<$99,$1d,$b7,$d3,$e3,$c2,$98,$ce>
;IID_IDirect3DTexture9 GUID $85c31227,$3de5,$4f00,<$9b,$3a,$f1,$1a,$c3,$8c,$18,$b5>
;IID_IDirect3DCubeTexture9 GUID $fff32f81,$d953,$473a,<$92,$23,$93,$d6,$52,$ab,$a9,$3f>
;IID_IDirect3DVolumeTexture9 GUID $2518526c,$e789,$4111,<$a7,$b9,$47,$ef,$32,$8d,$13,$e6>
;IID_IDirect3DVertexBuffer9 GUID $b64bb1b5,$fd70,$4df6,<$bf,$91,$19,$d0,$a1,$24,$55,$e3>
;IID_IDirect3DIndexBuffer9 GUID $7c9dd65e,$d3f7,$4529,<$ac,$ee,$78,$58,$30,$ac,$de,$35>
;IID_IDirect3DSurface9 GUID $cfbaf3a,$9ff6,$429a,<$99,$b3,$a2,$79,$6a,$f8,$b8,$9b>
;IID_IDirect3DVolume9 GUID $24f416e6,$1f67,$4aa7,<$b8,$8e,$d3,$3f,$6f,$31,$28,$a1>
;IID_IDirect3DSwapChain9 GUID $794950f2,$adfc,$458a,<$90,$5e,$10,$a1,$b,$b,$50,$3b>
;IID_IDirect3DVertexDeclaration9 GUID $dd13c59c,$36fa,$4098,<$a8,$fb,$c7,$ed,$39,$dc,$85,$46>
;IID_IDirect3DVertexShader9 GUID $efc5557e,$6265,$4613,<$8a,$94,$43,$85,$78,$89,$eb,$36>
;IID_IDirect3DPixelShader9 GUID $6d3bdbdc,$5b02,$4415,<$b8,$52,$ce,$5e,$8b,$cc,$b2,$89>
;IID_IDirect3DStateBlock9 GUID $b07c4fe5,$310d,$4ba8,<$a2,$3c,$4f,$f,$20,$6f,$21,$8b>
;IID_IDirect3DQuery9 GUID $d9771460,$a695,$4f26,<$bb,$d3,$27,$b8,$40,$b5,$41,$cc>
;IID_HelperName GUID $e4a36723,$fdfe,$4b22,<$b1,$46,$3c,$4,$c0,$7f,$4c,$c8>
;IID_IDirect3D9Ex GUID $02177241,$69FC,$400C,<$8F,$F1,$93,$A4,$4D,$F6,$86,$1D>
;IID_IDirect3DDevice9Ex GUID $b18b10ce,$2649,$405a,<$87,$f,$95,$f7,$77,$d4,$31,$3a>
;IID_IDirect3DSwapChain9Ex GUID $91886caf,$1c3d,$4d2e,<$a0,$ab,$3e,$4c,$7d,$8d,$33,3>

;Copyright (C) Microsoft Corporation.  All Rights Reserved.
;File:       d3d9types.h
;Content:    Direct3D capabilities include file

macro D3DCOLORARGB a, r, g, b {
      VALUE = (a << 24) or (r << 16) or (g << 8) or b
}

macro D3DCOLORRGBA r, g, b, a {
      VALUE = (a << 24) or (r << 16) or (g << 8) or b
}

macro D3DCOLORXRGB r, g, b {
      VALUE = ($ff shl 24) or (r << 16) or (g << 8) or b
}

macro D3DCOLOR_XYUV y, u, v {
      VALUE = ($ff << 24) or (y << 16) or (u << 8) or v
}

macro D3DCOLOR_AYUV a, y, u, v {
      VALUE = (a shl 24) or (y << 16) or (u << 8) or v
}
;next three structs extra's
struct D3DCOLORVERTEX
       x dd ?
       y dd ?
       z dd ?
       color dd ?
ends

struct D3DNORMALVERTEX
       x dd ?
       y dd ?
       z dd ?
       nx dd ?
       ny dd ?
       nz dd ?
ends

struct D3DNORMALUVVERTEX
       x dd ?
       y dd ?
       z dd ?
       nx dd ?
       ny dd ?
       nz dd ?
       u dd ?
       v dd ?
ends
;-----------------------------

struct D3DVECTOR
       x dd ?
       y dd ?
       z dd ?
ends

struct D3DCOLORVALUE
       r dd ?
       g dd ?
       b dd ?
       a dd ?
ends

struct D3DRECT
       x1 dd ?
       y1 dd ?
       x2 dd ?
       y2 dd ?
ends

struct D3DMATRIX
       _11 dd ?
       _12 dd ?
       _13 dd ?
       _14 dd ?
       _21 dd ?
       _22 dd ?
       _23 dd ?
       _24 dd ?
       _31 dd ?
       _32 dd ?
       _33 dd ?
       _34 dd ?
       _41 dd ?
       _42 dd ?
       _43 dd ?
       _44 dd ?
ends

struct D3DVIEWPORT9
       X dd ?
       Y dd ?
       Width dd ?
       Height dd ?
       MinZ dd ?
       MaxZ dd ?
ends

D3DMAXUSERCLIPPLANES = 32

D3DCLIPPLANE0 = (1 shl 0)
D3DCLIPPLANE1 = (1 shl 1)
D3DCLIPPLANE2 = (1 shl 2)
D3DCLIPPLANE3 = (1 shl 3)
D3DCLIPPLANE4 = (1 shl 4)
D3DCLIPPLANE5 = (1 shl 5)

D3DCS_LEFT = 1
D3DCS_RIGHT = 2
D3DCS_TOP = 4
D3DCS_BOTTOM = 8
D3DCS_FRONT = $10
D3DCS_BACK = $20
D3DCS_PLANE0 = $40
D3DCS_PLANE1 = $80
D3DCS_PLANE2 = $100
D3DCS_PLANE3 = $200
D3DCS_PLANE4 = $400
D3DCS_PLANE5 = $800

D3DCS_ALL = (D3DCS_LEFT or D3DCS_RIGHT or D3DCS_TOP or D3DCS_BOTTOM or D3DCS_FRONT or\
	     D3DCS_BACK  or D3DCS_PLANE0  or D3DCS_PLANE1 or D3DCS_PLANE2 or D3DCS_PLANE3 or\
	     D3DCS_PLANE4 or D3DCS_PLANE5)

struct D3DCLIPSTATUS9
       ClipUnion dd ?
       ClipIntersection dd ?
ends

struct D3DMATERIAL9
       Diffuse D3DCOLORVALUE
       Ambient D3DCOLORVALUE
       Specular D3DCOLORVALUE
       Emissive D3DCOLORVALUE
       Power dd ?
ends

D3DLIGHT_POINT = 1
D3DLIGHT_SPOT = 2
D3DLIGHT_DIRECTIONAL = 3

struct D3DLIGHT9
       Type dd ?
       Diffuse D3DCOLORVALUE
       Specular D3DCOLORVALUE
       Ambient D3DCOLORVALUE
       Position D3DVECTOR
       Direction D3DVECTOR
       Range dd ?
       Falloff dd ?
       Attenuation0 dd ?
       Attenuation1 dd ?
       Attenuation2 dd ?
       Theta dd ?
       Phi dd ?
ends

D3DCLEAR_TARGET = $1
D3DCLEAR_ZBUFFER = $2
D3DCLEAR_STENCIL = $4

D3DSHADE_FLAT = 1
D3DSHADE_GOURAUD = 2
D3DSHADE_PHONG = 3

D3DFILL_POINT = 1
D3DFILL_WIREFRAME = 2
D3DFILL_SOLID = 3

D3DBLEND_ZERO = 1
D3DBLEND_ONE = 2
D3DBLEND_SRCCOLOR = 3
D3DBLEND_INVSRCCOLOR = 4
D3DBLEND_SRCALPHA = 5
D3DBLEND_INVSRCALPHA = 6
D3DBLEND_DESTALPHA = 7
D3DBLEND_INVDESTALPHA = 8
D3DBLEND_DESTCOLOR = 9
D3DBLEND_INVDESTCOLOR = 10
D3DBLEND_SRCALPHASAT = 11
D3DBLEND_BOTHSRCALPHA = 12
D3DBLEND_BOTHINVSRCALPHA = 13
D3DBLEND_BLENDFACTOR = 14
D3DBLEND_INVBLENDFACTOR = 15
D3DBLEND_SRCCOLOR2 = 16
D3DBLEND_INVSRCCOLOR2 = 17

D3DBLENDOP_ADD = 1
D3DBLENDOP_SUBTRACT = 2
D3DBLENDOP_REVSUBTRACT = 3
D3DBLENDOP_MIN = 4
D3DBLENDOP_MAX = 5

D3DTADDRESS_WRAP = 1
D3DTADDRESS_MIRROR = 2
D3DTADDRESS_CLAMP = 3
D3DTADDRESS_BORDER = 4
D3DTADDRESS_MIRRORONCE = 5

D3DCULL_NONE = 1
D3DCULL_CW = 2
D3DCULL_CCW = 3

D3DCMP_NEVER = 1
D3DCMP_LESS = 2
D3DCMP_EQUAL = 3
D3DCMP_LESSEQUAL = 4
D3DCMP_GREATER = 5
D3DCMP_NOTEQUAL = 6
D3DCMP_GREATEREQUAL = 7
D3DCMP_ALWAYS = 8

D3DSTENCILOP_KEEP = 1
D3DSTENCILOP_ZERO = 2
D3DSTENCILOP_REPLACE = 3
D3DSTENCILOP_INCRSAT = 4
D3DSTENCILOP_DECRSAT = 5
D3DSTENCILOP_INVERT = 6
D3DSTENCILOP_INCR = 7
D3DSTENCILOP_DECR = 8

D3DFOG_NONE = 0
D3DFOG_EXP = 1
D3DFOG_EXP2 = 2
D3DFOG_LINEAR = 3

D3DZB_FALSE = 0
D3DZB_TRUE = 1
D3DZB_USEW = 2

D3DPT_POINTLIST = 1
D3DPT_LINELIST = 2
D3DPT_LINESTRIP = 3
D3DPT_TRIANGLELIST = 4
D3DPT_TRIANGLESTRIP = 5
D3DPT_TRIANGLEFAN = 6

D3DTS_VIEW = 2
D3DTS_PROJECTION = 3
D3DTS_TEXTURE0 = 16
D3DTS_TEXTURE1 = 17
D3DTS_TEXTURE2 = 18
D3DTS_TEXTURE3 = 19
D3DTS_TEXTURE4 = 20
D3DTS_TEXTURE5 = 21
D3DTS_TEXTURE6 = 22
D3DTS_TEXTURE7 = 23

;D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
D3DTS_WORLD = 256
D3DTS_WORLD1 = 257
D3DTS_WORLD2 = 258
D3DTS_WORLD3 = 259

D3DRS_ZENABLE = 7
D3DRS_FILLMODE = 8
D3DRS_SHADEMODE = 9
D3DRS_ZWRITEENABLE = 14
D3DRS_ALPHATESTENABLE = 15
D3DRS_LASTPIXEL = 16
D3DRS_SRCBLEND = 19
D3DRS_DESTBLEND = 20
D3DRS_CULLMODE = 22
D3DRS_ZFUNC = 23
D3DRS_ALPHAREF = 24
D3DRS_ALPHAFUNC = 25
D3DRS_DITHERENABLE = 26
D3DRS_ALPHABLENDENABLE = 27
D3DRS_FOGENABLE = 28
D3DRS_SPECULARENABLE = 29
D3DRS_FOGCOLOR = 34
D3DRS_FOGTABLEMODE = 35
D3DRS_FOGSTART = 36
D3DRS_FOGEND = 37
D3DRS_FOGDENSITY = 38
D3DRS_RANGEFOGENABLE = 48
D3DRS_STENCILENABLE = 52
D3DRS_STENCILFAIL = 53
D3DRS_STENCILZFAIL = 54
D3DRS_STENCILPASS = 55
D3DRS_STENCILFUNC = 56
D3DRS_STENCILREF = 57
D3DRS_STENCILMASK = 58
D3DRS_STENCILWRITEMASK = 59
D3DRS_TEXTUREFACTOR = 60
D3DRS_WRAP0 = 128
D3DRS_WRAP1 = 129
D3DRS_WRAP2 = 130
D3DRS_WRAP3 = 131
D3DRS_WRAP4 = 132
D3DRS_WRAP5 = 133
D3DRS_WRAP6 = 134
D3DRS_WRAP7 = 135
D3DRS_CLIPPING = 136
D3DRS_LIGHTING = 137
D3DRS_AMBIENT = 139
D3DRS_FOGVERTEXMODE = 140
D3DRS_COLORVERTEX = 141
D3DRS_LOCALVIEWER = 142
D3DRS_NORMALIZENORMALS = 143
D3DRS_DIFFUSEMATERIALSOURCE = 145
D3DRS_SPECULARMATERIALSOURCE = 146
D3DRS_AMBIENTMATERIALSOURCE = 147
D3DRS_EMISSIVEMATERIALSOURCE = 148
D3DRS_VERTEXBLEND = 151
D3DRS_CLIPPLANEENABLE = 152
D3DRS_POINTSIZE = 154
D3DRS_POINTSIZE_MIN = 155
D3DRS_POINTSPRITEENABLE = 156
D3DRS_POINTSCALEENABLE = 157
D3DRS_POINTSCALE_A = 158
D3DRS_POINTSCALE_B = 159
D3DRS_POINTSCALE_C = 160
D3DRS_MULTISAMPLEANTIALIAS = 161
D3DRS_MULTISAMPLEMASK = 162
D3DRS_PATCHEDGESTYLE = 163
D3DRS_DEBUGMONITORTOKEN = 165
D3DRS_POINTSIZE_MAX = 166
D3DRS_INDEXEDVERTEXBLENDENABLE = 167
D3DRS_COLORWRITEENABLE = 168
D3DRS_TWEENFACTOR = 170
D3DRS_BLENDOP = 171
D3DRS_POSITIONDEGREE = 172
D3DRS_NORMALDEGREE = 173
D3DRS_SCISSORTESTENABLE = 174
D3DRS_SLOPESCALEDEPTHBIAS = 175
D3DRS_ANTIALIASEDLINEENABLE = 176
D3DRS_MINTESSELLATIONLEVEL = 178
D3DRS_MAXTESSELLATIONLEVEL = 179
D3DRS_ADAPTIVETESS_X = 180
D3DRS_ADAPTIVETESS_Y = 181
D3DRS_ADAPTIVETESS_Z = 182
D3DRS_ADAPTIVETESS_W = 183
D3DRS_ENABLEADAPTIVETESSELLATION = 184
D3DRS_TWOSIDEDSTENCILMODE = 185
D3DRS_CCW_STENCILFAIL = 186
D3DRS_CCW_STENCILZFAIL = 187
D3DRS_CCW_STENCILPASS = 188
D3DRS_CCW_STENCILFUNC = 189
D3DRS_COLORWRITEENABLE1 = 190
D3DRS_COLORWRITEENABLE2 = 191
D3DRS_COLORWRITEENABLE3 = 192
D3DRS_BLENDFACTOR = 193
D3DRS_SRGBWRITEENABLE = 194
D3DRS_DEPTHBIAS = 195
D3DRS_WRAP8 = 198
D3DRS_WRAP9 = 199
D3DRS_WRAP10 = 200
D3DRS_WRAP11 = 201
D3DRS_WRAP12 = 202
D3DRS_WRAP13 = 203
D3DRS_WRAP14 = 204
D3DRS_WRAP15 = 205
D3DRS_SEPARATEALPHABLENDENABLE = 206
D3DRS_SRCBLENDALPHA = 207
D3DRS_DESTBLENDALPHA = 208
D3DRS_BLENDOPALPHA = 209

D3D_MAX_SIMULTANEOUS_RENDERTARGETS = 4

D3DMCS_MATERIAL = 0
D3DMCS_COLOR1 = 1
D3DMCS_COLOR2 = 2

D3DRENDERSTATE_WRAPBIAS = 128

D3DWRAP_U = 1
D3DWRAP_V = 2
D3DWRAP_W = 4

D3DWRAPCOORD_0 = 1
D3DWRAPCOORD_1 = 2
D3DWRAPCOORD_2 = 4
D3DWRAPCOORD_3 = 8

D3DCOLORWRITEENABLE_RED = (1 shl 0)
D3DCOLORWRITEENABLE_GREEN = (1 shl 1)
D3DCOLORWRITEENABLE_BLUE = (1 shl 2)
D3DCOLORWRITEENABLE_ALPHA = (1 shl 3)

D3DTSS_COLOROP = 1
D3DTSS_COLORARG1 = 2
D3DTSS_COLORARG2 = 3
D3DTSS_ALPHAOP = 4
D3DTSS_ALPHAARG1 = 5
D3DTSS_ALPHAARG2 = 6
D3DTSS_BUMPENVMAT00 = 7
D3DTSS_BUMPENVMAT01 = 8
D3DTSS_BUMPENVMAT10 = 9
D3DTSS_BUMPENVMAT11 = 10
D3DTSS_TEXCOORDINDEX = 11
D3DTSS_BUMPENVLSCALE = 22
D3DTSS_BUMPENVLOFFSET = 23
D3DTSS_TEXTURETRANSFORMFLAGS = 24
D3DTSS_COLORARG0 = 26
D3DTSS_ALPHAARG0 = 27
D3DTSS_RESULTARG = 28
D3DTSS_CONSTANT = 32

D3DSAMP_ADDRESSU = 1
D3DSAMP_ADDRESSV = 2
D3DSAMP_ADDRESSW = 3
D3DSAMP_BORDERCOLOR = 4
D3DSAMP_MAGFILTER = 5
D3DSAMP_MINFILTER = 6
D3DSAMP_MIPFILTER = 7
D3DSAMP_MIPMAPLODBIAS = 8
D3DSAMP_MAXMIPLEVEL = 9
D3DSAMP_MAXANISOTROPY = 10
D3DSAMP_SRGBTEXTURE = 11
D3DSAMP_ELEMENTINDEX = 12
D3DSAMP_DMAPOFFSET = 13

D3DDMAPSAMPLER = 256

D3DVERTEXTEXTURESAMPLER0 = (D3DDMAPSAMPLER+1)
D3DVERTEXTEXTURESAMPLER1 = (D3DDMAPSAMPLER+2)
D3DVERTEXTEXTURESAMPLER2 = (D3DDMAPSAMPLER+3)
D3DVERTEXTEXTURESAMPLER3 = (D3DDMAPSAMPLER+4)

D3DTSS_TCI_PASSTHRU = 0
D3DTSS_TCI_CAMERASPACENORMAL = $10000
D3DTSS_TCI_CAMERASPACEPOSITION = $20000
D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR = $30000
D3DTSS_TCI_SPHEREMAP = $40000

D3DTOP_DISABLE = 1
D3DTOP_SELECTARG1 = 2
D3DTOP_SELECTARG2 = 3
D3DTOP_MODULATE = 4
D3DTOP_MODULATE2X = 5
D3DTOP_MODULATE4X = 6
D3DTOP_ADD =  7
D3DTOP_ADDSIGNED = 8
D3DTOP_ADDSIGNED2X = 9
D3DTOP_SUBTRACT = 10
D3DTOP_ADDSMOOTH = 11
D3DTOP_BLENDDIFFUSEALPHA = 12
D3DTOP_BLENDTEXTUREALPHA = 13
D3DTOP_BLENDFACTORALPHA = 14
D3DTOP_BLENDTEXTUREALPHAPM = 15
D3DTOP_BLENDCURRENTALPHA = 16
D3DTOP_PREMODULATE = 17
D3DTOP_MODULATEALPHA_ADDCOLOR = 18
D3DTOP_MODULATECOLOR_ADDALPHA = 19
D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20
D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21
D3DTOP_BUMPENVMAP = 22
D3DTOP_BUMPENVMAPLUMINANCE = 23
D3DTOP_DOTPRODUCT3 = 24
D3DTOP_MULTIPLYADD = 25
D3DTOP_LERP = 26

D3DTA_SELECTMASK = 0
D3DTA_DIFFUSE = 0
D3DTA_CURRENT = 1
D3DTA_TEXTURE = 2
D3DTA_TFACTOR = 3
D3DTA_SPECULAR = 4
D3DTA_TEMP = 5
D3DTA_CONSTANT = 6
D3DTA_COMPLEMENT = $10
D3DTA_ALPHAREPLICATE = $20

D3DTEXF_NONE = 0
D3DTEXF_POINT = 1
D3DTEXF_LINEAR = 2
D3DTEXF_ANISOTROPIC = 3
D3DTEXF_PYRAMIDALQUAD = 6
D3DTEXF_GAUSSIANQUAD = 7
D3DTEXF_CONVOLUTIONMONO = 8

D3DPV_DONOTCOPYDATA = (1 shl 0)

D3DFVF_RESERVED0 = 1
D3DFVF_POSITION_MASK = $400E
D3DFVF_XYZ = 2
D3DFVF_XYZRHW = 4
D3DFVF_XYZB1 = 6
D3DFVF_XYZB2 = 8
D3DFVF_XYZB3 = $a
D3DFVF_XYZB4 = $c
D3DFVF_XYZB5 = $e
D3DFVF_XYZW = $4002
D3DFVF_NORMAL = $10
D3DFVF_PSIZE = $20
D3DFVF_DIFFUSE = $40
D3DFVF_SPECULAR = $80
D3DFVF_TEXCOUNT_MASK = $f00
D3DFVF_TEXCOUNT_SHIFT = 8
D3DFVF_TEX0 = 0
D3DFVF_TEX1 = $100
D3DFVF_TEX2 = $200
D3DFVF_TEX3 = $300
D3DFVF_TEX4 = $400
D3DFVF_TEX5 = $500
D3DFVF_TEX6 = $600
D3DFVF_TEX7 = $700
D3DFVF_TEX8 = $800
D3DFVF_LASTBETA_UBYTE4 = $1000
D3DFVF_LASTBETA_D3DCOLOR = $8000
D3DFVF_RESERVED2 = $6000

D3DDECLUSAGE_POSITION = 0
D3DDECLUSAGE_BLENDWEIGHT = 1
D3DDECLUSAGE_BLENDINDICES = 2
D3DDECLUSAGE_NORMAL = 3
D3DDECLUSAGE_PSIZE = 4
D3DDECLUSAGE_TEXCOORD = 5
D3DDECLUSAGE_TANGENT = 6
D3DDECLUSAGE_BINORMAL = 7
D3DDECLUSAGE_TESSFACTOR = 8
D3DDECLUSAGE_POSITIONT = 9
D3DDECLUSAGE_COLOR = 10
D3DDECLUSAGE_FOG = 11
D3DDECLUSAGE_DEPTH = 12
D3DDECLUSAGE_SAMPLE = 13

MAXD3DDECLUSAGE = D3DDECLUSAGE_SAMPLE
MAXD3DDECLUSAGEINDEX = 15
MAXD3DDECLLENGTH = 64

D3DDECLMETHOD_DEFAULT = 0
D3DDECLMETHOD_PARTIALU = 1
D3DDECLMETHOD_PARTIALV = 2
D3DDECLMETHOD_CROSSUV = 3
D3DDECLMETHOD_UV = 4
D3DDECLMETHOD_LOOKUP = 5
D3DDECLMETHOD_LOOKUPPRESAMPLED = 6

MAXD3DDECLMETHOD = D3DDECLMETHOD_LOOKUPPRESAMPLED

D3DDECLTYPE_FLOAT1 = 0
D3DDECLTYPE_FLOAT2 = 1
D3DDECLTYPE_FLOAT3 = 2
D3DDECLTYPE_FLOAT4 = 3
D3DDECLTYPE_D3DCOLOR = 4
D3DDECLTYPE_UBYTE4 = 5
D3DDECLTYPE_SHORT2 = 6
D3DDECLTYPE_SHORT4 = 7
D3DDECLTYPE_UBYTE4N = 8
D3DDECLTYPE_SHORT2N = 9
D3DDECLTYPE_SHORT4N = 10
D3DDECLTYPE_USHORT2N = 11
D3DDECLTYPE_USHORT4N = 12
D3DDECLTYPE_UDEC3 = 13
D3DDECLTYPE_DEC3N = 14
D3DDECLTYPE_FLOAT16_2 = 15
D3DDECLTYPE_FLOAT16_4 = 16
D3DDECLTYPE_UNUSED = 17

MAXD3DDECLTYPE = D3DDECLTYPE_UNUSED

struct D3DVERTEXELEMENT9
       Stream dw ?
       Offset dw ?
       Type db ?
       Method db ?
       Usage db ?
       UsageIndex db ?
ends

D3DDECL_END equ $FF, 0, D3DDECLTYPE_UNUSED, 0, 0, 0

D3DDP_MAXTEXCOORD = 8

D3DSTREAMSOURCE_INDEXEDDATA = (1 shl 30)
D3DSTREAMSOURCE_INSTANCEDATA = (2 shl 30)

D3DSI_OPCODE_MASK = $FFFF
D3DSI_INSTLENGTH_MASK = $F000000
D3DSI_INSTLENGTH_SHIFT = 24

D3DSIO_NOP = 0
D3DSIO_MOV = 1
D3DSIO_ADD = 2
D3DSIO_SUB = 3
D3DSIO_MAD = 4
D3DSIO_MUL = 5
D3DSIO_RCP = 6
D3DSIO_RSQ = 7
D3DSIO_DP3 = 8
D3DSIO_DP4 = 9
D3DSIO_MIN = 10
D3DSIO_MAX = 11
D3DSIO_SLT = 12
D3DSIO_SGE = 13
D3DSIO_EXP = 14
D3DSIO_LOG = 15
D3DSIO_LIT = 16
D3DSIO_DST = 17
D3DSIO_LRP = 18
D3DSIO_FRC = 19
D3DSIO_M4x4 = 20
D3DSIO_M4x3 = 21
D3DSIO_M3x4 = 22
D3DSIO_M3x3 = 23
D3DSIO_M3x2 = 24
D3DSIO_CALL = 25
D3DSIO_CALLNZ = 26
D3DSIO_LOOP = 27
D3DSIO_RET = 28
D3DSIO_ENDLOOP = 29
D3DSIO_LABEL = 30
D3DSIO_DCL = 31
D3DSIO_POW = 32
D3DSIO_CRS = 33
D3DSIO_SGN = 34
D3DSIO_ABS = 35
D3DSIO_NRM = 36
D3DSIO_SINCOS = 37
D3DSIO_REP = 38
D3DSIO_ENDREP = 39
D3DSIO_IF = 40
D3DSIO_IFC = 41
D3DSIO_ELSE = 42
D3DSIO_ENDIF = 43
D3DSIO_BREAK = 44
D3DSIO_BREAKC = 45
D3DSIO_MOVA = 46
D3DSIO_DEFB = 47
D3DSIO_DEFI = 48
D3DSIO_TEXCOORD = 64
D3DSIO_TEXKILL = 65
D3DSIO_TEX = 66
D3DSIO_TEXBEM = 67
D3DSIO_TEXBEML = 68
D3DSIO_TEXREG2AR = 69
D3DSIO_TEXREG2GB = 70
D3DSIO_TEXM3x2PAD = 71
D3DSIO_TEXM3x2TEX = 72
D3DSIO_TEXM3x3PAD = 73
D3DSIO_TEXM3x3TEX = 74
D3DSIO_RESERVED0 = 75
D3DSIO_TEXM3x3SPEC = 76
D3DSIO_TEXM3x3VSPEC = 77
D3DSIO_EXPP = 78
D3DSIO_LOGP = 79
D3DSIO_CND = 80
D3DSIO_DEF = 81
D3DSIO_TEXREG2RGB = 82
D3DSIO_TEXDP3TEX = 83
D3DSIO_TEXM3x2DEPTH = 84
D3DSIO_TEXDP3 = 85
D3DSIO_TEXM3x3 = 86
D3DSIO_TEXDEPTH = 87
D3DSIO_CMP = 88
D3DSIO_BEM = 89
D3DSIO_DP2ADD = 90
D3DSIO_DSX = 91
D3DSIO_DSY = 92
D3DSIO_TEXLDD = 93
D3DSIO_SETP = 94
D3DSIO_TEXLDL = 95
D3DSIO_BREAKP = 96
D3DSIO_PHASE = $FFFD
D3DSIO_COMMENT = $FFFE
D3DSIO_END = $FFFF

D3DSINCOSCONST1 equ -1.5500992e-006f, -2.1701389e-005f,  0.0026041667f, 0.00026041668f
D3DSINCOSCONST2 equ -0.020833334f, -0.12500000f, 1.0f, 0.50000000f

D3DSI_COISSUE = $40000000

D3DSP_OPCODESPECIFICCONTROL_MASK = $ff0000
D3DSP_OPCODESPECIFICCONTROL_SHIFT = 16

D3DSI_TEXLD_PROJECT = (0x01 shl D3DSP_OPCODESPECIFICCONTROL_SHIFT)
D3DSI_TEXLD_BIAS = (0x02 shl D3DSP_OPCODESPECIFICCONTROL_SHIFT)

D3DSPC_RESERVED0= 0
D3DSPC_GT = 1
D3DSPC_EQ = 2
D3DSPC_GE = 3
D3DSPC_LT = 4
D3DSPC_NE = 5
D3DSPC_LE = 6
D3DSPC_RESERVED1= 7

D3DSHADER_COMPARISON_SHIFT = D3DSP_OPCODESPECIFICCONTROL_SHIFT
D3DSHADER_COMPARISON_MASK = (7 shl D3DSHADER_COMPARISON_SHIFT)

D3DSHADER_INSTRUCTION_PREDICATED = (1 shl 28)

D3DSP_DCL_USAGE_SHIFT = 0
D3DSP_DCL_USAGE_MASK = $f
D3DSP_DCL_USAGEINDEX_SHIFT = 16
D3DSP_DCL_USAGEINDEX_MASK = $f0000

D3DSP_TEXTURETYPE_SHIFT = 27
D3DSP_TEXTURETYPE_MASK = $78000000

D3DSTT_UNKNOWN = (0 shl D3DSP_TEXTURETYPE_SHIFT)
D3DSTT_2D = (2 shl D3DSP_TEXTURETYPE_SHIFT)
D3DSTT_CUBE = (3 shl D3DSP_TEXTURETYPE_SHIFT)
D3DSTT_VOLUME = (4 shl D3DSP_TEXTURETYPE_SHIFT)

D3DSP_REGNUM_MASK = $7FF
D3DSP_WRITEMASK_0 = $10000
D3DSP_WRITEMASK_1 = $20000
D3DSP_WRITEMASK_2 = $40000
D3DSP_WRITEMASK_3 = $80000
D3DSP_WRITEMASK_ALL = $F0000
D3DSP_DSTMOD_SHIFT = 20
D3DSP_DSTMOD_MASK = $F00000

D3DSPDM_NONE = (0 shl D3DSP_DSTMOD_SHIFT)
D3DSPDM_SATURATE = (1 shl D3DSP_DSTMOD_SHIFT)
D3DSPDM_PARTIALPRECISION = (2 shl D3DSP_DSTMOD_SHIFT)
D3DSPDM_MSAMPCENTROID = (4 shl D3DSP_DSTMOD_SHIFT)

D3DSP_DSTSHIFT_SHIFT = 24
D3DSP_DSTSHIFT_MASK = $F000000
D3DSP_REGTYPE_SHIFT = 28
D3DSP_REGTYPE_SHIFT2 = 8
D3DSP_REGTYPE_MASK = $70000000
D3DSP_REGTYPE_MASK2 = $1800

D3DSPR_TEMP = 0
D3DSPR_INPUT = 1
D3DSPR_CONST = 2
D3DSPR_ADDR = 3
D3DSPR_TEXTURE = 3
D3DSPR_RASTOUT = 4
D3DSPR_ATTROUT = 5
D3DSPR_TEXCRDOUT = 6
D3DSPR_OUTPUT = 6
D3DSPR_CONSTINT = 7
D3DSPR_COLOROUT = 8
D3DSPR_DEPTHOUT = 9
D3DSPR_SAMPLER = 10
D3DSPR_CONST2 = 11
D3DSPR_CONST3 = 12
D3DSPR_CONST4 = 13
D3DSPR_CONSTBOOL = 14
D3DSPR_LOOP = 15
D3DSPR_TEMPFLOAT16 = 16
D3DSPR_MISCTYPE = 17
D3DSPR_LABEL = 18
D3DSPR_PREDICATE = 19

D3DSMO_POSITION = 0
D3DSMO_FACE = 1

D3DSRO_POSITION = 0
D3DSRO_FOG = 1
D3DSRO_POINT_SIZE = 2

D3DVS_ADDRESSMODE_SHIFT = 13
D3DVS_ADDRESSMODE_MASK = (1 shl D3DVS_ADDRESSMODE_SHIFT)

D3DVS_ADDRMODE_ABSOLUTE = (0 shl D3DVS_ADDRESSMODE_SHIFT)
D3DVS_ADDRMODE_RELATIVE = (1 shl D3DVS_ADDRESSMODE_SHIFT)

D3DSHADER_ADDRESSMODE_SHIFT = 13
D3DSHADER_ADDRESSMODE_MASK = (1 shl D3DSHADER_ADDRESSMODE_SHIFT)
D3DSHADER_ADDRMODE_ABSOLUTE = (0 shl D3DSHADER_ADDRESSMODE_SHIFT)
D3DSHADER_ADDRMODE_RELATIVE = (1 shl D3DSHADER_ADDRESSMODE_SHIFT)

D3DVS_SWIZZLE_SHIFT = 16
D3DVS_SWIZZLE_MASK = $FF0000
D3DVS_X_X = (0 shl D3DVS_SWIZZLE_SHIFT)
D3DVS_X_Y = (1 shl D3DVS_SWIZZLE_SHIFT)
D3DVS_X_Z = (2 shl D3DVS_SWIZZLE_SHIFT)
D3DVS_X_W = (3 shl D3DVS_SWIZZLE_SHIFT)
D3DVS_Y_X = (0 shl (D3DVS_SWIZZLE_SHIFT + 2))
D3DVS_Y_Y = (1 shl (D3DVS_SWIZZLE_SHIFT + 2))
D3DVS_Y_Z = (2 shl (D3DVS_SWIZZLE_SHIFT + 2))
D3DVS_Y_W = (3 shl (D3DVS_SWIZZLE_SHIFT + 2))
D3DVS_Z_X = (0 shl (D3DVS_SWIZZLE_SHIFT + 4))
D3DVS_Z_Y = (1 shl (D3DVS_SWIZZLE_SHIFT + 4))
D3DVS_Z_Z = (2 shl (D3DVS_SWIZZLE_SHIFT + 4))
D3DVS_Z_W = (3 shl (D3DVS_SWIZZLE_SHIFT + 4))
D3DVS_W_X = (0 shl (D3DVS_SWIZZLE_SHIFT + 6))
D3DVS_W_Y = (1 shl (D3DVS_SWIZZLE_SHIFT + 6))
D3DVS_W_Z = (2 shl (D3DVS_SWIZZLE_SHIFT + 6))
D3DVS_W_W = (3 shl (D3DVS_SWIZZLE_SHIFT + 6))
D3DVS_NOSWIZZLE = (D3DVS_X_X or D3DVS_Y_Y or D3DVS_Z_Z or D3DVS_W_W)

D3DSP_SWIZZLE_SHIFT = 16
D3DSP_SWIZZLE_MASK = $FF0000

D3DSP_NOSWIZZLE = (0 shl (D3DSP_SWIZZLE_SHIFT + 0)) or (1 shl (D3DSP_SWIZZLE_SHIFT + 2)) or \
		  (2 shl (D3DSP_SWIZZLE_SHIFT + 4)) or (3 shl (D3DSP_SWIZZLE_SHIFT + 6))

D3DSP_REPLICATERED = (0 shl (D3DSP_SWIZZLE_SHIFT + 0)) or (0 shl (D3DSP_SWIZZLE_SHIFT + 2)) or \
		     (0 shl (D3DSP_SWIZZLE_SHIFT + 4)) or (0 shl (D3DSP_SWIZZLE_SHIFT + 6))

D3DSP_REPLICATEGREEN = (1 shl (D3DSP_SWIZZLE_SHIFT + 0)) or (1 shl (D3DSP_SWIZZLE_SHIFT + 2)) or \
		       (1 shl (D3DSP_SWIZZLE_SHIFT + 4)) or (1 shl (D3DSP_SWIZZLE_SHIFT + 6))

D3DSP_REPLICATEBLUE = (2 shl (D3DSP_SWIZZLE_SHIFT + 0)) or (2 shl (D3DSP_SWIZZLE_SHIFT + 2)) or \
		      (2 shl (D3DSP_SWIZZLE_SHIFT + 4)) or (2 shl (D3DSP_SWIZZLE_SHIFT + 6))

D3DSP_REPLICATEALPHA = (3 shl (D3DSP_SWIZZLE_SHIFT + 0)) or (3 shl (D3DSP_SWIZZLE_SHIFT + 2)) or \
		       (3 shl (D3DSP_SWIZZLE_SHIFT + 4)) or (3 shl (D3DSP_SWIZZLE_SHIFT + 6))

D3DSP_SRCMOD_SHIFT = 24
D3DSP_SRCMOD_MASK = $F000000

D3DSPSM_NONE = (0 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_NEG = (1 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_BIAS = (2 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_BIASNEG = (3 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_SIGN = (4 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_SIGNNEG = (5 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_COMP = (6 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_X2 = (7 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_X2NEG = (8 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_DZ = (9 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_DW = (10 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_ABS = (11 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_ABSNEG = (12 shl D3DSP_SRCMOD_SHIFT)
D3DSPSM_NOT = (13 shl D3DSP_SRCMOD_SHIFT)

macro D3DPS_VERSION _Major, _Minor {
      VALUE = $FFFF0000 or ((_Major shl 8) or (_Minor))
}

macro D3DVS_VERSION _Major, _Minor {
      VALUE = $FFFE0000 or ((_Major shl 8) or (_Minor))
}

;D3DSHADER_VERSION_MAJOR(_Version) (((_Version)>>8)&0xFF)
;D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF)

D3DSI_COMMENTSIZE_SHIFT = 16
D3DSI_COMMENTSIZE_MASK = $7FFF0000
;D3DSHADER_COMMENT(_DWordSize) =\
;          ((((_DWordSize)<<D3DSI_COMMENTSIZE_SHIFT)&D3DSI_COMMENTSIZE_MASK)|D3DSIO_COMMENT)

D3DPS_END = $FFFF
D3DVS_END = $FFFF

D3DBASIS_BEZIER = 0
D3DBASIS_BSPLINE = 1
D3DBASIS_CATMULL_ROM = 2

D3DDEGREE_LINEAR = 1
D3DDEGREE_QUADRATIC = 2
D3DDEGREE_CUBIC = 3
D3DDEGREE_QUINTIC = 5

D3DPATCHEDGE_DISCRETE = 0
D3DPATCHEDGE_CONTINUOUS = 1

D3DSBT_ALL = 1
D3DSBT_PIXELSTATE = 2
D3DSBT_VERTEXSTATE = 3

D3DVBF_DISABLE	= 0
D3DVBF_1WEIGHTS = 1
D3DVBF_2WEIGHTS = 2
D3DVBF_3WEIGHTS = 3
D3DVBF_TWEENING = 255
D3DVBF_0WEIGHTS = 256

D3DTTFF_DISABLE = 0
D3DTTFF_COUNT1 = 1
D3DTTFF_COUNT2 = 2
D3DTTFF_COUNT3 = 3
D3DTTFF_COUNT4 = 4
D3DTTFF_PROJECTED = 256

D3DFVF_TEXTUREFORMAT2 = 0
D3DFVF_TEXTUREFORMAT1 = 3
D3DFVF_TEXTUREFORMAT3 = 1
D3DFVF_TEXTUREFORMAT4 = 2

;D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
;D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
;D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
;D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))

D3DDEVTYPE_HAL = 1
D3DDEVTYPE_REF = 2
D3DDEVTYPE_SW = 3
D3DDEVTYPE_NULLREF = 4

D3DMULTISAMPLE_NONE = 0
D3DMULTISAMPLE_NONMASKABLE = 1
D3DMULTISAMPLE_2_SAMPLES = 2
D3DMULTISAMPLE_3_SAMPLES = 3
D3DMULTISAMPLE_4_SAMPLES = 4
D3DMULTISAMPLE_5_SAMPLES = 5
D3DMULTISAMPLE_6_SAMPLES = 6
D3DMULTISAMPLE_7_SAMPLES = 7
D3DMULTISAMPLE_8_SAMPLES = 8
D3DMULTISAMPLE_9_SAMPLES = 9
D3DMULTISAMPLE_10_SAMPLES = 10
D3DMULTISAMPLE_11_SAMPLES = 11
D3DMULTISAMPLE_12_SAMPLES = 12
D3DMULTISAMPLE_13_SAMPLES = 13
D3DMULTISAMPLE_14_SAMPLES = 14
D3DMULTISAMPLE_15_SAMPLES = 15
D3DMULTISAMPLE_16_SAMPLES = 16

D3DFMT_UNKNOWN =  0
D3DFMT_R8G8B8 = 20
D3DFMT_A8R8G8B8 = 21
D3DFMT_X8R8G8B8 = 22
D3DFMT_R5G6B5 = 23
D3DFMT_X1R5G5B5 = 24
D3DFMT_A1R5G5B5 = 25
D3DFMT_A4R4G4B4 = 26
D3DFMT_R3G3B2 = 27
D3DFMT_A8 = 28
D3DFMT_A8R3G3B2 = 29
D3DFMT_X4R4G4B4 = 30
D3DFMT_A2B10G10R10 = 31
D3DFMT_A8B8G8R8 = 32
D3DFMT_X8B8G8R8 = 33
D3DFMT_G16R16 = 34
D3DFMT_A2R10G10B10 = 35
D3DFMT_A16B16G16R16 = 36
D3DFMT_A8P8 = 40
D3DFMT_P8 = 41
D3DFMT_L8 = 50
D3DFMT_A8L8 = 51
D3DFMT_A4L4 = 52
D3DFMT_V8U8 = 60
D3DFMT_L6V5U5 = 61
D3DFMT_X8L8V8U8 = 62
D3DFMT_Q8W8V8U8 = 63
D3DFMT_V16U16 = 64
D3DFMT_A2W10V10U10 = 67
D3DFMT_UYVY equ 'UYVY'
D3DFMT_R8G8_B8G8 equ 'RGBG'
D3DFMT_YUY2 equ 'YUY2'
D3DFMT_G8R8_G8B8 equ 'GRGB'
D3DFMT_DXT1 equ 'DXT1'
D3DFMT_DXT2 equ 'DXT2'
D3DFMT_DXT3 equ 'DXT3'
D3DFMT_DXT4 equ 'DXT4'
D3DFMT_DXT5 equ 'DXT5'
D3DFMT_D16_LOCKABLE  = 70
D3DFMT_D32 = 71
D3DFMT_D15S1 = 73
D3DFMT_D24S8 = 75
D3DFMT_D24X8 = 77
D3DFMT_D24X4S4 = 79
D3DFMT_D16 = 80
D3DFMT_D32F_LOCKABLE = 82
D3DFMT_D24FS8 = 83
D3DFMT_D32_LOCKABLE = 84
D3DFMT_S8_LOCKABLE = 85
D3DFMT_L16 = 81
D3DFMT_VERTEXDATA = 100
D3DFMT_INDEX16 = 101
D3DFMT_INDEX32 = 102
D3DFMT_Q16W16V16U16 = 110
D3DFMT_MULTI2_ARGB8 equ 'MET1'
D3DFMT_R16F = 111
D3DFMT_G16R16F = 112
D3DFMT_A16B16G16R16F = 113
D3DFMT_R32F = 114
D3DFMT_G32R32F = 115
D3DFMT_A32B32G32R32F = 116
D3DFMT_CxV8U8 = 117
D3DFMT_A1 = 118
D3DFMT_BINARYBUFFER = 199

struct D3DDISPLAYMODE
       Width dd ?
       Height dd ?
       RefreshRate dd ?
       Format dd ?
ends

struct D3DDEVICECREATIONPARAMETERS
       AdapterOrdinal dd ?
       DeviceType dd ?
       hFocusWindow dq ?
       BehaviorFlags dd ?,?
ends

D3DSWAPEFFECT_DISCARD = 1
D3DSWAPEFFECT_FLIP = 2
D3DSWAPEFFECT_COPY = 3

D3DPOOL_DEFAULT = 0
D3DPOOL_MANAGED = 1
D3DPOOL_SYSTEMMEM = 2
D3DPOOL_SCRATCH = 3

D3DPRESENT_RATE_DEFAULT = 0

struct D3DPRESENTPARAMETERS
       BackBufferWidth dd ?
       BackBufferHeight dd ?
       BackBufferFormat dd ?
       BackBufferCount dd ?
       MultiSampleType dd ?
       MultiSampleQuality dd ?
       SwapEffect dd ?,?
       hDeviceWindow dq ?
       Windowed dd ?
       EnableAutoDepthStencil dd ?
       AutoDepthStencilFormat dd ?
       Flags dd ?
       FullScreen_RefreshRateInHz dd ?
       PresentationInterval dd ?
ends

D3DPRESENTFLAG_LOCKABLE_BACKBUFFER = 1
D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL = 2
D3DPRESENTFLAG_DEVICECLIP = 4
D3DPRESENTFLAG_VIDEO = $10

D3DPRESENTFLAG_NOAUTOROTATE = $20
D3DPRESENTFLAG_UNPRUNEDMODE = $40

struct D3DGAMMARAMP
       red dw 256 dup(?)
       green dw 256 dup(?)
       blue dw 256 dup(?)
ends

D3DBACKBUFFER_TYPE_MONO = 0
D3DBACKBUFFER_TYPE_LEFT = 1
D3DBACKBUFFER_TYPE_RIGHT = 2

D3DRTYPE_SURFACE =  1
D3DRTYPE_VOLUME =  2
D3DRTYPE_TEXTURE =  3
D3DRTYPE_VOLUMETEXTURE =  4
D3DRTYPE_CUBETEXTURE =	5
D3DRTYPE_VERTEXBUFFER =  6
D3DRTYPE_INDEXBUFFER =	7

D3DUSAGE_RENDERTARGET = 1
D3DUSAGE_DEPTHSTENCIL = 2
D3DUSAGE_DYNAMIC = $200
D3DUSAGE_NONSECURE = $800000
D3DUSAGE_AUTOGENMIPMAP = $400
D3DUSAGE_DMAP = $4000
D3DUSAGE_QUERY_LEGACYBUMPMAP = $8000
D3DUSAGE_QUERY_SRGBREAD = $10000
D3DUSAGE_QUERY_FILTER = $20000
D3DUSAGE_QUERY_SRGBWRITE = $40000
D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING = $80000
D3DUSAGE_QUERY_VERTEXTEXTURE = $100000
D3DUSAGE_QUERY_WRAPANDMIP = $200000
D3DUSAGE_WRITEONLY = 8
D3DUSAGE_SOFTWAREPROCESSING  = $10
D3DUSAGE_DONOTCLIP = $20
D3DUSAGE_POINTS = $40
D3DUSAGE_RTPATCHES = $80
D3DUSAGE_NPATCHES = $100
D3DUSAGE_TEXTAPI = $10000000

D3DCUBEMAP_FACE_POSITIVE_X = 0
D3DCUBEMAP_FACE_NEGATIVE_X = 1
D3DCUBEMAP_FACE_POSITIVE_Y = 2
D3DCUBEMAP_FACE_NEGATIVE_Y = 3
D3DCUBEMAP_FACE_POSITIVE_Z = 4
D3DCUBEMAP_FACE_NEGATIVE_Z = 5

D3DLOCK_READONLY = $10
D3DLOCK_DISCARD = $2000
D3DLOCK_NOOVERWRITE = $1000
D3DLOCK_NOSYSLOCK = $800
D3DLOCK_DONOTWAIT = $4000
D3DLOCK_NO_DIRTY_UPDATE = $8000

struct D3DVERTEXBUFFERDESC
       Format dd ?
       Type dd ?
       Usage dd ?
       Pool dd ?
       Size dd ?
       FVF dd ?
ends

struct D3DINDEXBUFFERDESC
       Format dd ?
       Type dd ?
       Usage dd ?
       Pool dd ?
       Size dd ?
ends

struct D3DSURFACEDESC
       Format dd ?
       Type dd ?
       Usage dd ?
       Pool dd ?
       MultiSampleType dd ?
       MultiSampleQuality dd ?
       Width dd ?
       Height dd ?
ends

struct D3DVOLUMEDESC
       Format dd ?
       Type dd ?
       Usage dd ?
       Pool dd ?
       Width dd ?
       Height dd ?
       Depth dd ?
ends

struct D3DLOCKEDRECT
       Pitch dd ?,?
       pBits dq ?
ends

struct D3DBOX
       Left dd ?
       Top dd ?
       Right dd ?
       Bottom dd ?
       Front dd ?
       Back dd ?
ends

struct D3DLOCKEDBOX
       RowPitch dd ?
       SlicePitch dd ?
       pBits dq ?
ends

struct D3DRANGE
       Offset dd ?
       Size dd ?
ends

struct D3DRECTPATCHINFO
       StartVertexOffsetWidth dd ?
       StartVertexOffsetHeight dd ?
       Width dd ?
       Height dd ?
       Stride dd ?
       Basis dd ?
       Degree dd ?
ends

struct D3DTRIPATCHINFO
       StartVertexOffset dd ?
       NumVertices dd ?
       Basis dd ?
       Degree dd ?
ends

MAX_DEVICE_IDENTIFIER_STRING = 512

struct D3DADAPTERIDENTIFIER9
       Driver db MAX_DEVICE_IDENTIFIER_STRING dup(?)
       Description db MAX_DEVICE_IDENTIFIER_STRING dup(?)
       DeviceName db 32 dup(?)
       DriverVersion dq ?
       VendorId dd ?
       DeviceId dd ?
       SubSysId dd ?
       Revision dd ?
       DeviceIdentifier GUID
       WHQLLevel dd ?,?
ends

struct D3DRASTERSTATUS
       InVBlank dd ?
       ScanLine dd ?
ends

D3DDMT_ENABLE = 0
D3DDMT_DISABLE = 1

D3DQUERYTYPE_VCACHE = 4
D3DQUERYTYPE_RESOURCEMANAGER = 5
D3DQUERYTYPE_VERTEXSTATS = 6
D3DQUERYTYPE_EVENT = 8
D3DQUERYTYPE_OCCLUSION = 9
D3DQUERYTYPE_TIMESTAMP = 10
D3DQUERYTYPE_TIMESTAMPDISJOINT = 11
D3DQUERYTYPE_TIMESTAMPFREQ = 12
D3DQUERYTYPE_PIPELINETIMINGS = 13
D3DQUERYTYPE_INTERFACETIMINGS = 14
D3DQUERYTYPE_VERTEXTIMINGS = 15
D3DQUERYTYPE_PIXELTIMINGS = 16
D3DQUERYTYPE_BANDWIDTHTIMINGS = 17
D3DQUERYTYPE_CACHEUTILIZATION = 18

D3DISSUE_END = (1 shl 0)
D3DISSUE_BEGIN = (1 shl 1)
D3DGETDATA_FLUSH = (1 shl 0)

struct D3DRESOURCESTATS
       bThrashing dd ?
       ApproxBytesDownloaded dd ?
       NumEvicts dd ?
       NumVidCreates dd ?
       LastPri dd ?
       NumUsed dd ?
       NumUsedInVidMem dd ?
       WorkingSet dd ?
       WorkingSetBytes dd ?
       TotalManaged dd ?
       TotalBytes dd ?
ends

D3DRTYPECOUNT = D3DRTYPE_INDEXBUFFER + 1

struct D3DDEVINFORESOURCEMANAGER
	  stats D3DRESOURCESTATS
		db (D3DRTYPECOUNT-1) * sizeof.D3DRESOURCESTATS dup(?)
ends

struct D3DDEVINFOD3DVERTEXSTATS
       NumRenderedTriangles dd ?
       NumExtraClippingTriangles dd ?
ends

struct D3DDEVINFOVCACHE
       Pattern dd ?
       OptMethod dd ?
       CacheSize dd ?
       MagicNumber dd ?
ends

struct D3DDEVINFOD3D9PIPELINETIMINGS
       VertexProcessingTimePercent dd ?
       PixelProcessingTimePercent dd ?
       OtherGPUProcessingTimePercent dd ?
       GPUIdleTimePercent dd ?
ends

struct D3DDEVINFOD3D9INTERFACETIMINGS
       WaitingForGPUToUseApplicationResourceTimePercent dd ?
       WaitingForGPUToAcceptMoreCommandsTimePercent dd ?
       WaitingForGPUToStayWithinLatencyTimePercent dd ?
       WaitingForGPUExclusiveResourceTimePercent dd ?
       WaitingForGPUOtherTimePercent dd ?
ends

struct D3DDEVINFOD3D9STAGETIMINGS
       MemoryProcessingPercent dd ?
       ComputationProcessingPercent dd ?
ends

struct D3DDEVINFOD3D9BANDWIDTHTIMINGS
       MaxBandwidthUtilized dd ?
       FrontEndUploadMemoryUtilizedPercent dd ?
       VertexRateUtilizedPercent dd ?
       TriangleSetupRateUtilizedPercent dd ?
       FillRateUtilizedPercent dd ?
ends

struct D3DDEVINFOD3D9CACHEUTILIZATION
       TextureCacheHitRate dd ?
       PostTransformVertexCacheHitRate dd ?
ends

D3DCOMPOSERECTS_COPY = 1
D3DCOMPOSERECTS_OR = 2
D3DCOMPOSERECTS_AND = 3
D3DCOMPOSERECTS_NEG = 4

struct D3DCOMPOSERECTDESC
       X dw ?
       Y dw ?
       Width dw ?
       Height dw ?
ends

struct D3DCOMPOSERECTDESTINATION
       SrcRectIndex dw ?
       Reserved dw ?
       X dw ?
       Y dw ?
ends

D3DCOMPOSERECTS_MAXNUMRECTS = $FFFF
D3DCONVOLUTIONMONO_MAXWIDTH = 7
D3DCONVOLUTIONMONO_MAXHEIGHT = D3DCONVOLUTIONMONO_MAXWIDTH
D3DFMT_A1_SURFACE_MAXWIDTH = 8192
D3DFMT_A1_SURFACE_MAXHEIGHT = 2048

struct D3DPRESENTSTATS
       PresentCount dd ?
       PresentRefreshCount dd ?
       SyncRefreshCount dd ?
       SyncQPCTime dq ?
       SyncGPUTime dq ?
ends

D3DSCANLINEORDERING_UNKNOWN = 0
D3DSCANLINEORDERING_PROGRESSIVE = 1
D3DSCANLINEORDERING_INTERLACED = 2

struct D3DDISPLAYMODEEX
       Size dd ?
       Width dd ?
       Height dd ?
       RefreshRate dd ?
       Format dd ?
       ScanLineOrdering dd ?
ends

struct D3DDISPLAYMODEFILTER
       Size dd ?
       Format dd ?
       ScanLineOrdering dd ?
ends

D3DDISPLAYROTATION_IDENTITY = 1
D3DDISPLAYROTATION_90 = 2
D3DDISPLAYROTATION_180 = 3
D3DDISPLAYROTATION_270 = 4

D3D9_RESOURCE_PRIORITY_MINIMUM = $28000000
D3D9_RESOURCE_PRIORITY_LOW = $50000000
D3D9_RESOURCE_PRIORITY_NORMAL = $78000000
D3D9_RESOURCE_PRIORITY_HIGH = $a0000000
D3D9_RESOURCE_PRIORITY_MAXIMUM = $c8000000

;Copyright (C) Microsoft Corporation.  All Rights Reserved.
;File:       d3d9caps.h
;Content:    Direct3D capabilities include file
struct D3DVSHADERCAPS20
       Caps dd ?
       DynamicFlowControlDepth dd ?
       NumTemps dd ?
       StaticFlowControlDepth dd ?
ends

D3DVS20CAPS_PREDICATION = (1 shl 0)
D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH = 24
D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0
D3DVS20_MAX_NUMTEMPS = 32
D3DVS20_MIN_NUMTEMPS = 12
D3DVS20_MAX_STATICFLOWCONTROLDEPTH = 4
D3DVS20_MIN_STATICFLOWCONTROLDEPTH = 1

struct D3DPSHADERCAPS20
       Caps dd ?
       DynamicFlowControlDepth dd ?
       NumTemps dd ?
       StaticFlowControlDepth dd ?
       NumInstructionSlots dd ?
ends

D3DPS20CAPS_ARBITRARYSWIZZLE = (1 shl 0)
D3DPS20CAPS_GRADIENTINSTRUCTIONS = (1 shl 1)
D3DPS20CAPS_PREDICATION = (1 shl 2)
D3DPS20CAPS_NODEPENDENTREADLIMIT = (1 shl 3)
D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT = (1 shl 4)

D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH = 24
D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0
D3DPS20_MAX_NUMTEMPS = 32
D3DPS20_MIN_NUMTEMPS = 12
D3DPS20_MAX_STATICFLOWCONTROLDEPTH = 4
D3DPS20_MIN_STATICFLOWCONTROLDEPTH = 0
D3DPS20_MAX_NUMINSTRUCTIONSLOTS = 512
D3DPS20_MIN_NUMINSTRUCTIONSLOTS = 96

D3DMIN30SHADERINSTRUCTIONS = 512
D3DMAX30SHADERINSTRUCTIONS = 32768

struct D3DOVERLAYCAPS
       Caps dd ?
       MaxOverlayDisplayWidth dd ?
       MaxOverlayDisplayHeight dd ?
ends

D3DOVERLAYCAPS_FULLRANGERGB = 1
D3DOVERLAYCAPS_LIMITEDRANGERGB = 2
D3DOVERLAYCAPS_YCbCr_BT601 = 4
D3DOVERLAYCAPS_YCbCr_BT709 = 8
D3DOVERLAYCAPS_YCbCr_BT601_xvYCC = $10
D3DOVERLAYCAPS_YCbCr_BT709_xvYCC = $20
D3DOVERLAYCAPS_STRETCHX = $40
D3DOVERLAYCAPS_STRETCHY = $80

struct D3DCONTENTPROTECTIONCAPS
       Caps dd ?
       KeyExchangeType GUID
       BufferAlignmentStart dd ?
       BlockAlignmentSize dd ?
       ProtectedMemorySize dq ?
ends

D3DCPCAPS_SOFTWARE = 1
D3DCPCAPS_HARDWARE = 2
D3DCPCAPS_PROTECTIONALWAYSON = 4
D3DCPCAPS_PARTIALDECRYPTION = 8
D3DCPCAPS_CONTENTKEY = $10
D3DCPCAPS_FRESHENSESSIONKEY = $20
D3DCPCAPS_ENCRYPTEDREADBACK = $40
D3DCPCAPS_ENCRYPTEDREADBACKKEY = $80
D3DCPCAPS_SEQUENTIAL_CTR_IV = $100
D3DCPCAPS_ENCRYPTSLICEDATAONLY = $200

;D3DCRYPTOTYPE_AES128_CTR GUID $9b6bd711,$4f74,$41c9,<$9e,$7b,$b,$e2,$d7,$d9,$3b,$4f>
;D3DCRYPTOTYPE_PROPRIETARY GUID $ab4e9afd,$1d1c,$46e6,<$a7,$2f,8,$69,$91,$7b,$d,$e8>
;D3DKEYEXCHANGE_RSAES_OAEP GUID $c1949895,$d72a,$4a1d,<$8e,$5d,$ed,$85,$7d,$17,$15,$20>
;D3DKEYEXCHANGE_DXVA GUID $43d3775c,$38e5,$4924,<$8d,$86,$d3,$fc,$cf,$15,$3e,$9b>

struct D3DCAPS9
       DeviceType dd ?
       AdapterOrdinal dd ?
       Caps dd ?
       Caps2 dd ?
       Caps3 dd ?
       PresentationIntervals dd ?
       CursorCaps dd ?
       DevCaps dd ?
       PrimitiveMiscCaps dd ?
       RasterCaps dd ?
       ZCmpCaps dd ?
       SrcBlendCaps dd ?
       DestBlendCaps dd ?
       AlphaCmpCaps dd ?
       ShadeCaps dd ?
       TextureCaps dd ?
       TextureFilterCaps dd ?
       CubeTextureFilterCaps dd ?
       VolumeTextureFilterCaps dd ?
       TextureAddressCaps dd ?
       VolumeTextureAddressCaps dd ?
       LineCaps dd ?
       MaxTextureWidth dd ?
       MaxTextureHeight dd ?
       MaxVolumeExtent dd ?
       MaxTextureRepeat dd ?
       MaxTextureAspectRatio dd ?
       MaxAnisotropy dd ?
       MaxVertexW dd ?
       GuardBandLeft dd ?
       GuardBandTop dd ?
       GuardBandRight dd ?
       GuardBandBottom dd ?
       ExtentsAdjust dd ?
       StencilCaps dd ?
       FVFCaps dd ?
       TextureOpCaps dd ?
       MaxTextureBlendStages dd ?
       MaxSimultaneousTextures dd ?
       VertexProcessingCaps dd ?
       MaxActiveLights dd ?
       MaxUserClipPlanes dd ?
       MaxVertexBlendMatrices dd ?
       MaxVertexBlendMatrixIndex dd ?
       MaxPointSize dd ?
       MaxPrimitiveCount dd ?
       MaxVertexIndex dd ?
       MaxStreams dd ?
       MaxStreamStride dd ?
       VertexShaderVersion dd ?
       MaxVertexShaderConst dd ?
       PixelShaderVersion dd ?
       PixelShader1xMaxValue dd ?
       DevCaps2 dd ?
       MaxNpatchTessellationLevel dd ?
       Reserved5 dd ?
       MasterAdapterOrdinal dd ?
       AdapterOrdinalInGroup dd ?
       NumberOfAdaptersInGroup dd ?
       DeclTypes dd ?
       NumSimultaneousRTs dd ?
       StretchRectFilterCaps dd ?
       VS20Caps D3DVSHADERCAPS20
       PS20Caps D3DPSHADERCAPS20
       VertexTextureFilterCaps dd ?
       MaxVShaderInstructionsExecuted dd ?
       MaxPShaderInstructionsExecuted dd ?
       MaxVertexShader30InstructionSlots dd ?
       MaxPixelShader30InstructionSlots dd ?
ends

D3DCAPS_READ_SCANLINE = $20000

D3DCAPS2_FULLSCREENGAMMA = $20000
D3DCAPS2_CANCALIBRATEGAMMA = $100000
D3DCAPS2_RESERVED = $2000000
D3DCAPS2_CANMANAGERESOURCE = $10000000
D3DCAPS2_DYNAMICTEXTURES = $20000000
D3DCAPS2_CANAUTOGENMIPMAP = $40000000
D3DCAPS2_CANSHARERESOURCE = $80000000

D3DCAPS3_RESERVED = $8000001f
D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD = $20
D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION = $80
D3DCAPS3_COPY_TO_VIDMEM = $100
D3DCAPS3_COPY_TO_SYSTEMMEM = $200

D3DPRESENT_INTERVAL_DEFAULT = 0
D3DPRESENT_INTERVAL_ONE = 1
D3DPRESENT_INTERVAL_TWO = 2
D3DPRESENT_INTERVAL_THREE = 4
D3DPRESENT_INTERVAL_FOUR = 8
D3DPRESENT_INTERVAL_IMMEDIATE = $80000000

D3DCURSORCAPS_COLOR = 1
D3DCURSORCAPS_LOWRES = 2

D3DDEVCAPS_EXECUTESYSTEMMEMORY = $10
D3DDEVCAPS_EXECUTEVIDEOMEMORY = $20
D3DDEVCAPS_TLVERTEXSYSTEMMEMORY = $40
D3DDEVCAPS_TLVERTEXVIDEOMEMORY = $80
D3DDEVCAPS_TEXTURESYSTEMMEMORY = $100
D3DDEVCAPS_TEXTUREVIDEOMEMORY = $200
D3DDEVCAPS_DRAWPRIMTLVERTEX = $400
D3DDEVCAPS_CANRENDERAFTERFLIP = $800
D3DDEVCAPS_TEXTURENONLOCALVIDMEM = $1000
D3DDEVCAPS_DRAWPRIMITIVES2 = $2000
D3DDEVCAPS_SEPARATETEXTUREMEMORIES = $4000
D3DDEVCAPS_DRAWPRIMITIVES2EX = $8000
D3DDEVCAPS_HWTRANSFORMANDLIGHT = $10000
D3DDEVCAPS_CANBLTSYSTONONLOCAL = $20000
D3DDEVCAPS_HWRASTERIZATION = $80000
D3DDEVCAPS_PUREDEVICE = $100000
D3DDEVCAPS_QUINTICRTPATCHES = $200000
D3DDEVCAPS_RTPATCHES = $400000
D3DDEVCAPS_RTPATCHHANDLEZERO = $800000
D3DDEVCAPS_NPATCHES = $1000000

D3DPMISCCAPS_MASKZ = 2
D3DPMISCCAPS_CULLNONE = $10
D3DPMISCCAPS_CULLCW = $20
D3DPMISCCAPS_CULLCCW = $40
D3DPMISCCAPS_COLORWRITEENABLE = $80
D3DPMISCCAPS_CLIPPLANESCALEDPOINTS = $100
D3DPMISCCAPS_CLIPTLVERTS = $200
D3DPMISCCAPS_TSSARGTEMP = $400
D3DPMISCCAPS_BLENDOP = $800
D3DPMISCCAPS_NULLREFERENCE = $1000
D3DPMISCCAPS_INDEPENDENTWRITEMASKS = $4000
D3DPMISCCAPS_PERSTAGECONSTANT = $8000
D3DPMISCCAPS_FOGANDSPECULARALPHA = $10000
D3DPMISCCAPS_SEPARATEALPHABLEND = $20000
D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS = $40000
D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING = $80000
D3DPMISCCAPS_FOGVERTEXCLAMPED = $100000
D3DPMISCCAPS_POSTBLENDSRGBCONVERT = $200000

D3DLINECAPS_TEXTURE = 1
D3DLINECAPS_ZTEST = 2
D3DLINECAPS_BLEND = 4
D3DLINECAPS_ALPHACMP = 8
D3DLINECAPS_FOG = $10
D3DLINECAPS_ANTIALIAS = $20

D3DPRASTERCAPS_DITHER = 1
D3DPRASTERCAPS_ZTEST = $10
D3DPRASTERCAPS_FOGVERTEX = $80
D3DPRASTERCAPS_FOGTABLE = $100
D3DPRASTERCAPS_MIPMAPLODBIAS = $2000
D3DPRASTERCAPS_ZBUFFERLESSHSR = $8000
D3DPRASTERCAPS_FOGRANGE = $10000
D3DPRASTERCAPS_ANISOTROPY = $20000
D3DPRASTERCAPS_WBUFFER = $40000
D3DPRASTERCAPS_WFOG = $100000
D3DPRASTERCAPS_ZFOG = $200000
D3DPRASTERCAPS_COLORPERSPECTIVE = $400000
D3DPRASTERCAPS_SCISSORTEST = $1000000
D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS = $2000000
D3DPRASTERCAPS_DEPTHBIAS = $4000000
D3DPRASTERCAPS_MULTISAMPLE_TOGGLE = $8000000

D3DPCMPCAPS_NEVER = 1
D3DPCMPCAPS_LESS = 2
D3DPCMPCAPS_EQUAL = 4
D3DPCMPCAPS_LESSEQUAL = 8
D3DPCMPCAPS_GREATER = $10
D3DPCMPCAPS_NOTEQUAL = $20
D3DPCMPCAPS_GREATEREQUAL = $40
D3DPCMPCAPS_ALWAYS = $80

D3DPBLENDCAPS_ZERO = 1
D3DPBLENDCAPS_ONE = 2
D3DPBLENDCAPS_SRCCOLOR = 4
D3DPBLENDCAPS_INVSRCCOLOR = 8
D3DPBLENDCAPS_SRCALPHA = $10
D3DPBLENDCAPS_INVSRCALPHA = $20
D3DPBLENDCAPS_DESTALPHA = $40
D3DPBLENDCAPS_INVDESTALPHA = $80
D3DPBLENDCAPS_DESTCOLOR = $100
D3DPBLENDCAPS_INVDESTCOLOR = $200
D3DPBLENDCAPS_SRCALPHASAT = $400
D3DPBLENDCAPS_BOTHSRCALPHA = $800
D3DPBLENDCAPS_BOTHINVSRCALPHA = $1000
D3DPBLENDCAPS_BLENDFACTOR = $2000
D3DPBLENDCAPS_SRCCOLOR2 = $4000
D3DPBLENDCAPS_INVSRCCOLOR2 = $8000

D3DPSHADECAPS_COLORGOURAUDRGB = 8
D3DPSHADECAPS_SPECULARGOURAUDRGB = $200
D3DPSHADECAPS_ALPHAGOURAUDBLEND = $4000
D3DPSHADECAPS_FOGGOURAUD = $80000

D3DPTEXTURECAPS_PERSPECTIVE = 1
D3DPTEXTURECAPS_POW2 = 2
D3DPTEXTURECAPS_ALPHA = 4
D3DPTEXTURECAPS_SQUAREONLY = $20
D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE = $40
D3DPTEXTURECAPS_ALPHAPALETTE = $80
D3DPTEXTURECAPS_NONPOW2CONDITIONAL = $100
D3DPTEXTURECAPS_PROJECTED = $400
D3DPTEXTURECAPS_CUBEMAP = $800
D3DPTEXTURECAPS_VOLUMEMAP = $2000
D3DPTEXTURECAPS_MIPMAP = $4000
D3DPTEXTURECAPS_MIPVOLUMEMAP = $8000
D3DPTEXTURECAPS_MIPCUBEMAP = $10000
D3DPTEXTURECAPS_CUBEMAP_POW2 = $20000
D3DPTEXTURECAPS_VOLUMEMAP_POW2 = $40000
D3DPTEXTURECAPS_NOPROJECTEDBUMPENV = $200000

D3DPTFILTERCAPS_MINFPOINT = $100
D3DPTFILTERCAPS_MINFLINEAR = $200
D3DPTFILTERCAPS_MINFANISOTROPIC = $400
D3DPTFILTERCAPS_MINFPYRAMIDALQUAD = $800
D3DPTFILTERCAPS_MINFGAUSSIANQUAD = $1000
D3DPTFILTERCAPS_MIPFPOINT = $10000
D3DPTFILTERCAPS_MIPFLINEAR = $20000
D3DPTFILTERCAPS_CONVOLUTIONMONO = $40000
D3DPTFILTERCAPS_MAGFPOINT = $1000000
D3DPTFILTERCAPS_MAGFLINEAR = $2000000
D3DPTFILTERCAPS_MAGFANISOTROPIC = $4000000
D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD = $8000000
D3DPTFILTERCAPS_MAGFGAUSSIANQUAD = $10000000

D3DPTADDRESSCAPS_WRAP = 1
D3DPTADDRESSCAPS_MIRROR = 2
D3DPTADDRESSCAPS_CLAMP = 4
D3DPTADDRESSCAPS_BORDER = 8
D3DPTADDRESSCAPS_INDEPENDENTUV = $10
D3DPTADDRESSCAPS_MIRRORONCE = $20

D3DSTENCILCAPS_KEEP = 1
D3DSTENCILCAPS_ZERO = 2
D3DSTENCILCAPS_REPLACE = 4
D3DSTENCILCAPS_INCRSAT = 8
D3DSTENCILCAPS_DECRSAT = $10
D3DSTENCILCAPS_INVERT = $20
D3DSTENCILCAPS_INCR = $40
D3DSTENCILCAPS_DECR = $80
D3DSTENCILCAPS_TWOSIDED = $100

D3DTEXOPCAPS_DISABLE = 1
D3DTEXOPCAPS_SELECTARG1 = 2
D3DTEXOPCAPS_SELECTARG2 = 4
D3DTEXOPCAPS_MODULATE = 8
D3DTEXOPCAPS_MODULATE2X = $10
D3DTEXOPCAPS_MODULATE4X = $20
D3DTEXOPCAPS_ADD = $40
D3DTEXOPCAPS_ADDSIGNED = $80
D3DTEXOPCAPS_ADDSIGNED2X = $100
D3DTEXOPCAPS_SUBTRACT = $200
D3DTEXOPCAPS_ADDSMOOTH = $400
D3DTEXOPCAPS_BLENDDIFFUSEALPHA = $800
D3DTEXOPCAPS_BLENDTEXTUREALPHA = $1000
D3DTEXOPCAPS_BLENDFACTORALPHA = $2000
D3DTEXOPCAPS_BLENDTEXTUREALPHAPM = $4000
D3DTEXOPCAPS_BLENDCURRENTALPHA = $8000
D3DTEXOPCAPS_PREMODULATE = $10000
D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR = $20000
D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA = $40000
D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR = $80000
D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA = $100000
D3DTEXOPCAPS_BUMPENVMAP = $200000
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE = $400000
D3DTEXOPCAPS_DOTPRODUCT3 = $800000
D3DTEXOPCAPS_MULTIPLYADD = $1000000
D3DTEXOPCAPS_LERP = $2000000

D3DFVFCAPS_TEXCOORDCOUNTMASK = $ffff
D3DFVFCAPS_DONOTSTRIPELEMENTS = $80000
D3DFVFCAPS_PSIZE = $100000

D3DVTXPCAPS_TEXGEN = 1
D3DVTXPCAPS_MATERIALSOURCE7 = 2
D3DVTXPCAPS_DIRECTIONALLIGHTS = 8
D3DVTXPCAPS_POSITIONALLIGHTS = $10
D3DVTXPCAPS_LOCALVIEWER = $20
D3DVTXPCAPS_TWEENING = $40
D3DVTXPCAPS_TEXGEN_SPHEREMAP = $100
D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER = $200

D3DDEVCAPS2_STREAMOFFSET = 1
D3DDEVCAPS2_DMAPNPATCH = 2
D3DDEVCAPS2_ADAPTIVETESSRTPATCH = 4
D3DDEVCAPS2_ADAPTIVETESSNPATCH = 8
D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES = $10
D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH = $20
D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET = $40

D3DDTCAPS_UBYTE4 = 1
D3DDTCAPS_UBYTE4N = 2
D3DDTCAPS_SHORT2N = 4
D3DDTCAPS_SHORT4N = 8
D3DDTCAPS_USHORT2N = $10
D3DDTCAPS_USHORT4N = $20
D3DDTCAPS_UDEC3 = $40
D3DDTCAPS_DEC3N = $80
D3DDTCAPS_FLOAT16_2 = $100
D3DDTCAPS_FLOAT16_4 = $200

interface IDirect3D9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  RegisterSoftwareDevice,\
	  GetAdapterCount,\
	  GetAdapterIdentifier,\
	  GetAdapterModeCount,\
	  EnumAdapterModes,\
	  GetAdapterDisplayMode,\
	  CheckDeviceType,\
	  CheckDeviceFormat,\
	  CheckDeviceMultiSampleType,\
	  CheckDepthStencilMatch,\
	  CheckDeviceFormatConversion,\
	  GetDeviceCaps,\
	  GetAdapterMonitor,\
	  CreateDevice
    
interface IDirect3DDevice9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  TestCooperativeLevel,\
	  GetAvailableTextureMem,\
	  EvictManagedResources,\
	  GetDirect3D,\
	  GetDeviceCaps,\
	  GetDisplayMode,\
	  GetCreationParameters,\
	  SetCursorProperties,\
	  SetCursorPosition,\
	  ShowCursor,\
	  CreateAdditionalSwapChain,\
	  GetSwapChain,\
	  GetNumberOfSwapChains,\
	  Reset,\
	  Present,\
	  GetBackBuffer,\
	  GetRasterStatus,\
	  SetDialogBoxMode,\
	  SetGammaRamp,\
	  GetGammaRamp,\
	  CreateTexture,\
	  CreateVolumeTexture,\
	  CreateCubeTexture,\
	  CreateVertexBuffer,\
	  CreateIndexBuffer,\
	  CreateRenderTarget,\
	  CreateDepthStencilSurface,\
	  UpdateSurface,\
	  UpdateTexture,\
	  GetRenderTargetData,\
	  GetFrontBufferData,\
	  StretchRect,\
	  ColorFill,\
	  CreateOffscreenPlainSurface,\
	  SetRenderTarget,\
	  GetRenderTarget,\
	  SetDepthStencilSurface,\
	  GetDepthStencilSurface,\
	  BeginScene,\
	  EndScene,\
	  Clear,\
	  SetTransform,\
	  GetTransform,\
	  MultiplyTransform,\
	  SetViewport,\
	  GetViewport,\
	  SetMaterial,\
	  GetMaterial,\
	  SetLight,\
	  GetLight,\
	  LightEnable,\
	  GetLightEnable,\
	  SetClipPlane,\
	  GetClipPlane,\
	  SetRenderState,\
	  GetRenderState,\
	  CreateStateBlock,\
	  BeginStateBlock,\
	  EndStateBlock,\
	  SetClipStatus,\
	  GetClipStatus,\
	  GetTexture,\
	  SetTexture,\
	  GetTextureStageState,\
	  SetTextureStageState,\
	  GetSamplerState,\
	  SetSamplerState,\
	  ValidateDevice,\
	  SetPaletteEntries,\
	  GetPaletteEntries,\
	  SetCurrentTexturePalette,\
	  GetCurrentTexturePalette,\
	  SetScissorRect,\
	  GetScissorRect,\
	  SetSoftwareVertexProcessing,\
	  GetSoftwareVertexProcessing,\
	  SetNPatchMode,\
	  GetNPatchMode,\
	  DrawPrimitive,\
	  DrawIndexedPrimitive,\
	  DrawPrimitiveUP,\
	  DrawIndexedPrimitiveUP,\
	  ProcessVertices,\
	  CreateVertexDeclaration,\
	  SetVertexDeclaration,\
	  GetVertexDeclaration,\
	  SetFVF,\
	  GetFVF,\
	  CreateVertexShader,\
	  SetVertexShader,\
	  GetVertexShader,\
	  SetVertexShaderConstantF,\
	  GetVertexShaderConstantF,\
	  SetVertexShaderConstantI,\
	  GetVertexShaderConstantI,\
	  SetVertexShaderConstantB,\
	  GetVertexShaderConstantB,\
	  SetStreamSource,\
	  GetStreamSource,\
	  SetStreamSourceFreq,\
	  GetStreamSourceFreq,\
	  SetIndices,\
	  GetIndices,\
	  CreatePixelShader,\
	  SetPixelShader,\
	  GetPixelShader,\
	  SetPixelShaderConstantF,\
	  GetPixelShaderConstantF,\
	  SetPixelShaderConstantI,\
	  GetPixelShaderConstantI,\
	  SetPixelShaderConstantB,\
	  GetPixelShaderConstantB,\
	  DrawRectPatch,\
	  DrawTriPatch,\
	  DeletePatch,\
	  CreateQuery

interface IDirect3DStateBlock9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  Capture,\
	  Apply

interface IDirect3DSwapChain9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  Present,\
	  GetFrontBufferData,\
	  GetBackBuffer,\
	  GetRasterStatus,\
	  GetDisplayMode,\
	  GetDevice,\
	  GetPresentParameters

interface IDirect3DResource9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType
    
interface IDirect3DVertexDeclaration9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  GetDeclaration
    
interface IDirect3DVertexShader9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  GetFunction

interface IDirect3DPixelShader9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  GetFunction

interface IDirect3DBaseTexture9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType,\
	  SetLOD,\
	  GetLOD,\
	  GetLevelCount,\
	  SetAutoGenFilterType,\
	  GetAutoGenFilterType,\
	  GenerateMipSubLevels

interface IDirect3DTexture9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType,\
	  SetLOD,\
	  GetLOD,\
	  GetLevelCount,\
	  SetAutoGenFilterType,\
	  GetAutoGenFilterType,\
	  GenerateMipSubLevels,\
	  GetLevelDesc,\
	  GetSurfaceLevel,\
	  LockRect,\
	  UnlockRect,\
	  AddDirtyRect

interface IDirect3DVolumeTexture9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType,\
	  SetLOD,\
	  GetLOD,\
	  GetLevelCount,\
	  SetAutoGenFilterType,\
	  GetAutoGenFilterType,\
	  GenerateMipSubLevels,\
	  GetLevelDesc,\
	  GetVolumeLevel,\
	  LockBox,\
	  UnlockBox,\
	  AddDirtyBox
    
interface IDirect3DCubeTexture9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType,\
	  SetLOD,\
	  GetLOD,\
	  GetLevelCount,\
	  SetAutoGenFilterType,\
	  GetAutoGenFilterType,\
	  GenerateMipSubLevels,\
	  GetLevelDesc,\
	  GetCubeMapSurface,\
	  LockRect,\
	  UnlockRect,\
	  AddDirtyRect
    
interface IDirect3DVertexBuffer9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType,\
	  Lock,\
	  Unlock,\
	  GetDesc

interface IDirect3DIndexBuffer9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType,\
	  Lock,\
	  Unlock,\
	  GetDesc
    
interface IDirect3DSurface9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  SetPriority,\
	  GetPriority,\
	  PreLoad,\
	  GetType,\
	  GetContainer,\
	  GetDesc,\
	  LockRect,\
	  UnlockRect,\
	  GetDC,\
	  ReleaseDC
    
interface IDirect3DVolume9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  SetPrivateData,\
	  GetPrivateData,\
	  FreePrivateData,\
	  GetContainer,\
	  GetDesc,\
	  LockBox,\
	  UnlockBox
    
interface IDirect3DQuery9,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetDevice,\
	  GetType,\
	  GetDataSize,\
	  Issue,\
	  GetData
    
D3DSPD_IUNKNOWN = 1

D3DCREATE_FPU_PRESERVE = 2
D3DCREATE_MULTITHREADED = 4
D3DCREATE_PUREDEVICE = $10
D3DCREATE_SOFTWARE_VERTEXPROCESSING = $20
D3DCREATE_HARDWARE_VERTEXPROCESSING = $40
D3DCREATE_MIXED_VERTEXPROCESSING = $80
D3DCREATE_DISABLE_DRIVER_MANAGEMENT = $100
D3DCREATE_ADAPTERGROUP_DEVICE = $200
D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX = $400
D3DCREATE_NOWINDOWCHANGES = $800
D3DCREATE_DISABLE_PSGP_THREADING = $2000
D3DCREATE_ENABLE_PRESENTSTATS = $4000
D3DCREATE_DISABLE_PRINTSCREEN = $8000
D3DCREATE_SCREENSAVER = $10000000

D3DADAPTER_DEFAULT = 0

D3DENUM_WHQL_LEVEL = 2
D3DENUM_NO_DRIVERVERSION = 4

D3DSGR_NO_CALIBRATION = 0
D3DSGR_CALIBRATE = 1

D3DCURSOR_IMMEDIATE_UPDATE = 1

D3DPRESENT_BACK_BUFFERS_MAX = 3
D3DPRESENT_BACK_BUFFERS_MAX_EX = 30
D3DPRESENT_DONOTWAIT = 1
D3DPRESENT_LINEAR_CONTENT = 2
D3DPRESENT_DONOTFLIP = 4
D3DPRESENT_FLIPRESTART = 8
D3DPRESENT_VIDEO_RESTRICT_TO_MONITOR = $10

D3DERR_WRONGTEXTUREFORMAT = $88760818
D3DERR_UNSUPPORTEDCOLOROPERATION = $88760819
D3DERR_UNSUPPORTEDCOLORARG = $8876081a
D3DERR_UNSUPPORTEDALPHAOPERATION = $8876081b
D3DERR_UNSUPPORTEDALPHAARG = $8876081c
D3DERR_TOOMANYOPERATIONS = $8876081d
D3DERR_CONFLICTINGTEXTUREFILTER = $8876081e
D3DERR_UNSUPPORTEDFACTORVALUE = $8876081f
D3DERR_CONFLICTINGRENDERSTATE = $88760821
D3DERR_UNSUPPORTEDTEXTUREFILTER = $88760822
D3DERR_CONFLICTINGTEXTUREPALETTE = $88760826
D3DERR_DRIVERINTERNALERROR = $88760827
D3DERR_NOTFOUND = $88760866
D3DERR_MOREDATA = $88760867
D3DERR_DEVICELOST = $88760868
D3DERR_DEVICENOTRESET = $88760869
D3DERR_NOTAVAILABLE = $8876086a
D3DERR_OUTOFVIDEOMEMORY = $8876017c
D3DERR_INVALIDDEVICE = $8876086b
D3DERR_INVALIDCALL = $8876086c
D3DERR_DRIVERINVALIDCALL = $8876086d
D3DERR_WASSTILLDRAWING = $8876021c
D3DOK_NOAUTOGEN = $887686f

D3DERR_DEVICEREMOVED = $88760870
S_NOT_RESIDENT = $8760875
S_RESIDENT_IN_SHARED_MEMORY = $8760876
S_PRESENT_MODE_CHANGED = $8760877
S_PRESENT_OCCLUDED = $8760878
D3DERR_DEVICEHUNG = $88760874

interface IDirect3D9Ex,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  GetAdapterCount,\
	  GetAdapterIdentifier,\
	  GetAdapterModeCount,\
	  EnumAdapterModes,\
	  GetAdapterDisplayMode,\
	  CheckDeviceType,\
	  CheckDeviceFormat,\
	  CheckDeviceMultiSampleType,\
	  CheckDepthStencilMatch,\
	  CheckDeviceFormatConversion,\
	  GetDeviceCaps,\
	  GetAdapterMonitor,\
	  CreateDevice,\
	  GetAdapterModeCountEx,\
	  EnumAdapterModesEx,\
	  GetAdapterDisplayModeEx,\
	  CreateDeviceEx,\
	  GetAdapterLUID
    
interface IDirect3DDevice9Ex,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  TestCooperativeLevel,\
	  GetAvailableTextureMem,\
	  EvictManagedResources,\
	  GetDirect3D,\
	  GetDeviceCaps,\
	  GetDisplayMode,\
	  GetCreationParameters,\
	  SetCursorProperties,\
	  SetCursorPosition,\
	  ShowCursor,\
	  CreateAdditionalSwapChain,\
	  GetSwapChain,\
	  GetNumberOfSwapChains,\
	  Reset,\
	  Present,\
	  GetBackBuffer,\
	  GetRasterStatus,\
	  SetDialogBoxMode,\
	  SetGammaRamp,\
	  GetGammaRamp,\
	  CreateTexture,\
	  CreateVolumeTexture,\
	  CreateCubeTexture,\
	  CreateVertexBuffer,\
	  CreateIndexBuffer,\
	  CreateRenderTarget,\
	  CreateDepthStencilSurface,\
	  UpdateSurface,\
	  UpdateTexture,\
	  GetRenderTargetData,\
	  GetFrontBufferData,\
	  StretchRect,\
	  ColorFill,\
	  CreateOffscreenPlainSurface,\
	  SetRenderTarget,\
	  GetRenderTarget,\
	  SetDepthStencilSurface,\
	  GetDepthStencilSurface,\
	  BeginScene,\
	  EndScene,\
	  Clear,\
	  SetTransform,\
	  GetTransform,\
	  MultiplyTransform,\
	  SetViewport,\
	  GetViewport,\
	  SetMaterial,\
	  GetMaterial,\
	  SetLight,\
	  GetLight,\
	  LightEnable,\
	  GetLightEnable,\
	  SetClipPlane,\
	  GetClipPlane,\
	  SetRenderState,\
	  GetRenderState,\
	  CreateStateBlock,\
	  BeginStateBlock,\
	  EndStateBlock,\
	  SetClipStatus,\
	  GetClipStatus,\
	  GetTexture,\
	  SetTexture,\
	  GetTextureStageState,\
	  SetTextureStageState,\
	  GetSamplerState,\
	  SetSamplerState,\
	  ValidateDevice,\
	  SetPaletteEntries,\
	  GetPaletteEntries,\
	  SetCurrentTexturePalette,\
	  GetCurrentTexturePalette,\
	  SetScissorRect,\
	  GetScissorRect,\
	  SetSoftwareVertexProcessing,\
	  GetSoftwareVertexProcessing,\
	  SetNPatchMode,\
	  GetNPatchMode,\
	  DrawPrimitive,\
	  DrawIndexedPrimitive,\
	  DrawPrimitiveUP,\
	  DrawIndexedPrimitiveUP,\
	  ProcessVertices,\
	  CreateVertexDeclaration,\
	  SetVertexDeclaration,\
	  GetVertexDeclaration,\
	  SetFVF,\
	  GetFVF,\
	  CreateVertexShader,\
	  SetVertexShader,\
	  GetVertexShader,\
	  SetVertexShaderConstantF,\
	  GetVertexShaderConstantF,\
	  SetVertexShaderConstantI,\
	  GetVertexShaderConstantI,\
	  SetVertexShaderConstantB,\
	  GetVertexShaderConstantB,\
	  SetStreamSource,\
	  GetStreamSource,\
	  SetStreamSourceFreq,\
	  GetStreamSourceFreq,\
	  SetIndices,\
	  GetIndices,\
	  CreatePixelShader,\
	  SetPixelShader,\
	  GetPixelShader,\
	  SetPixelShaderConstantF,\
	  GetPixelShaderConstantF,\
	  SetPixelShaderConstantI,\
	  GetPixelShaderConstantI,\
	  SetPixelShaderConstantB,\
	  GetPixelShaderConstantB,\
	  DrawRectPatch,\
	  DrawTriPatch,\
	  DeletePatch,\
	  CreateQuery,\
	  SetConvolutionMonoKernel,\
	  ComposeRects,\
	  PresentEx,\
	  GetGPUThreadPriority,\
	  SetGPUThreadPriority,\
	  WaitForVBlank,\
	  CheckResourceResidency,\
	  SetMaximumFrameLatency,\
	  GetMaximumFrameLatency,\
	  CheckDeviceState,\
	  CreateRenderTargetEx,\
	  CreateOffscreenPlainSurfaceEx,\
	  CreateDepthStencilSurfaceEx,\
	  ResetEx,\
	  GetDisplayModeEx
    
interface IDirect3DSwapChain9Ex,\
	  QueryInterface,\
	  AddRef,\
	  Release,\
	  Present,\
	  GetFrontBufferData,\
	  GetBackBuffer,\
	  GetRasterStatus,\
	  GetDisplayMode,\
	  GetDevice,\
	  GetPresentParameters,\
	  GetLastPresentCount,\
	  GetPresentStats,\
	  GetDisplayModeEx
